<?php

namespace App\Jobs;

use App\Http\Service\CountryService;
use App\Http\Service\DeviceService;
use App\Model\Business;
use App\Model\House;
use App\Model\RestartLog;
use App\Model\TjCountry;
use App\Models\Contract;
use App\Models\MemberCoupon;
use App\Models\Order;
use App\Models\Paper;
use App\services\ImmService;
use App\User;
use App\Utils\Result;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Storage;

class CheckAuto implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    private $device;
    public $tries = 3;
    public $timeout = 120;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($device)
    {
        $this->device = $device;
        //因为要导入大文件 需要很久时间
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
            Log::info('queue-auto-restart:');
            $service = app()->make(DeviceService::class);
            $service->restart($this->device->mac);
            $save['sn'] = $this->device->sn;
            RestartLog::create($save);
    }
}

